package javabase.collection.list.serializable;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;
import java.util.Vector;

public class VectorSerial {

	public static void main(String[] args) {

		
		File file = new File("vector.out");

        ObjectOutputStream oout = null;
		try {
			oout = new ObjectOutputStream(new FileOutputStream(file));
			List<String> vector = new Vector<String>(20) {
				private static final long serialVersionUID = 1L;
				{
					add("社会");
					add("主义");
					add("好!");
				}
			};
			vector.add("4");
			vector.add("5");
			vector.add("6");
			vector.add("7");
			vector.add("8");
			vector.add("9");
			vector.add("10");
			vector.add("11");
			oout.writeObject(vector);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (oout != null) {
				try {
					oout.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
  
        ObjectInputStream oin = null;
		try {
			oin = new ObjectInputStream(new FileInputStream(file));
			Object vector = oin.readObject(); 
			System.out.println(vector);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}  catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				oin.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
